using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using hedefgrup.reports.renault.database;

public partial class adm_sqlRunner : reportPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        base.initialize();
        base.ensureAdministratorIsLoggedIn();

        string sql = base.getString("SQL");
        if (!string.IsNullOrEmpty(base.getString("RUN")))
        {
            if (base.getString("TYPE") == "NONQUERY")
            {
                db.execute(sql, new object[] { });
                Response.Write("<br /><br />SUCCESS<br /><br />");
            }
            else
            {
                DataTable dt = db.query(sql, new object[] { });
                Response.Write("<br /><br /><table><tr>");
                foreach (DataColumn dc in dt.Columns)
                {
                    Response.Write("<th>" + dc.ColumnName + "</th>");
                }
                Response.Write("</tr>");

                foreach (DataRow dr in dt.Rows)
                {
                    Response.Write("<tr>");
                    foreach (DataColumn dc in dt.Columns)
                    {
                        Response.Write("<td>" + Convert.ToString(dr[dc]) + "</td>");
                    }
                    Response.Write("</tr>");
                }
                Response.Write("</PRE>");
            }
        }
    }
}
